package com.xbongbong.saas.domain.dao;

import com.xbongbong.pro.domain.entity.UpdateDataEntity;
import com.xbongbong.saas.domain.entity.PaymentBalanceEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 预收款余额dao层接口
 *
 * @author 梁鲁江
 * @version v1.0
 * @date 2019/11/6 21:42
 * @since v1.0
 */
@Repository
@Mapper
public interface PaymentBalanceDao {
    /**
     * 插入数据
     *
     * @param entity 预收款实体数据
     * @return java.lang.Integer
     * @date 2019-01-29 21:03
     */
    Integer insert(PaymentBalanceEntity entity);
    /**
     * 更新数据
     * @param entity 预收款实体数据
     * @return java.lang.Integer
     * @date 2019-01-29 21:04
     */
//    Integer update(PaymentBalanceEntity entity);
    /**
     * 获取数据
     *
     * @param key 主键值
     * @param corpid 公司id
     * @date 2019-01-29 21:05
     */
    PaymentBalanceEntity getByKey(@Param("key") Long key, @Param("corpid") String corpid);

    /**
     * 根据客户id和corpid
     * @param customerId
     * @param corpid
     * @return
     */
    PaymentBalanceEntity getByCustomerId(@Param("customerId") Long customerId, @Param("corpid") String corpid);
    /**
     * 根据客户id和corpid
     * @param customerIds
     * @param corpid
     * @return
     */
    List<PaymentBalanceEntity> getByCustomerIds(@Param("customerIds") List<Long> customerIds, @Param("corpid") String corpid, @Param("columns") String columns);
    /**
     * 获取实体数
     *
     * @param param 查询参数
     * @return java.lang.Integer
     * @date 2019-01-30 10:20
     */
    Integer getEntitysCount(@Param("param") Map<String, Object> param);

    /**
     * 获取预收款实体集合
     *
     * @param param
     * @date 2019-02-22 20:14
     */
    List<PaymentBalanceEntity> findEntitys(@Param("param") Map<String, Object> param);

    /**
     * 批量删除
     * @param idIn
     * @param corpid 公司id
     * @return java.lang.Integer
     */
    Integer deleteBatch(@Param("list") List<Long> idIn, @Param("corpid") String corpid);
    /**
     * 根据corpid和customerId更新
     * @param advancePaymentBalance
     * @param corpid
     * @param customerId
     * @return
     */
    Integer updatePaymentBalanceByCorpidAndCustomerId(@Param("advancePaymentBalance")  Double advancePaymentBalance, @Param("corpid") String corpid, @Param("customerId") Long customerId);
    /**
     * 根据corpid和id更新
     * @param advancePaymentBalance
     * @param corpid
     * @param id
     * @return
     */
    Integer updatePaymentBalanceByCorpidAndId(@Param("advancePaymentBalance")  Double advancePaymentBalance, @Param("corpid") String corpid, @Param("id") Long id);

    /**
     * @description 根据客户id 更新 del和预收款余额
     * @author yanglei
     * @date 2022/12/19 19:22
     * @param advancePaymentBalance
     * @param corpid
     * @param customerId
     * @return Integer
     */
    Integer updatePaymentBalanceDelByCorpidAndCustomerId(@Param("advancePaymentBalance")  Double advancePaymentBalance, @Param("corpid") String corpid, @Param("customerId") Long customerId);


    /**
     * 根据corpid和id更新（注：该方法直接更新客户的预收款余额，而不是对原值增加）
     * @param advancePaymentBalance
     * @param corpid
     * @param id
     * @return
     */
    Integer updatePaymentBalanceById(@Param("advancePaymentBalance")  Double advancePaymentBalance, @Param("corpid") String corpid, @Param("id") Long id);
    /**
     * 根据corpid和id更新金额和del
     * @param advancePaymentBalance
     * @param corpid
     * @param id
     * @return
     */
    Integer updatePaymentBalanceDelByCorpidAndId(@Param("advancePaymentBalance")  Double advancePaymentBalance, @Param("corpid") String corpid, @Param("id") Long id);

    /**
     * 单个删除
     * @param key
     * @param corpid
     * @return
     */
    Integer deleteByKey(@Param("key") Long key, @Param("corpid") String corpid);

    /**
     * 根据corpid批量更新
     * @param list
     * @param corpid
     * @return
     */
    Integer updateBatchByCorpidAndCustomerId(@Param("list") List<PaymentBalanceEntity> list, @Param("corpid") String corpid);

    /**
     * 通过客户id批量更新客户的预收款余额：只用于脚本，直接重置余额值
     * @param list
     * @param corpid
     * @return java.lang.Integer
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    Integer updateBatchAdvanceByCorpidAndCustomerId(@Param("list") List<PaymentBalanceEntity> list, @Param("corpid") String corpid);

    /**
     * 更新更新时间
     *
     * @param updateTime
     * @param id
     * @param corpid
     * @return
     */
    Integer updateTime(@Param("updateTime") Long updateTime, @Param("id") Long id, @Param("corpid") String corpid);


    /**
     * 批量更新单个字段
     * @param list
     * @param corpid
     * @return
     */
    Integer updateBatch(@Param("list") List<UpdateDataEntity> list, @Param("corpid") String corpid);

}
